package field

import "gitee.com/yanwc/net/utils"

type (
	CommandWord    uint8 // 命令字
	CommandWordRaw [1]byte
)

const (
	WildCommandWord      CommandWord = 0x00 // 服务器透传命令字
	HeartBeatCommandWord CommandWord = 0x02 // 心跳
	WarnCommandWord      CommandWord = 0x05 // 告警
	LoginCommandWord     CommandWord = 0x23 // 登录
	StatusCommandWord    CommandWord = 0x51 // 状态上报
)

func (cw CommandWord) Raw() (out CommandWordRaw) {
	copy(out[:], utils.NumberToBytesWithBigEndian(cw))
	return
}

func (cw CommandWordRaw) Slice() []byte {
	return cw[:]
}

func (cw CommandWordRaw) Type() CommandWord {
	return utils.BytesToNumber[CommandWord](cw[:])
}
